/*
 * Copyright 2016-2016 the original author or authors.
 * Created on 2016/12/27 下午8:12
 */
package cn.com.geasy.base;

import cn.com.geasy.base.repoisitory.BaseRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/**
 * 请在此写下该类的说明
 *
 * @author Mechanic
 * @version 1.0
 */
@Service
public class BaseServiceImpl<T extends BaseEntity, ID extends Serializable> implements BaseService<T, ID>{

    @Autowired
    private BaseRepository<T, ID> baseRepository;

    @Override
    public T findOne(ID id) {
        return baseRepository.findOne(id);
    }

    @Override
    public List<T> findAll() {
        return baseRepository.findAll();
    }

    @Override
    public List<T> findAll(Sort sort) {
        return baseRepository.findAll(sort);
    }

    @Override
    public List<T> findAll(List<ID> ids) {
        return baseRepository.findAll(ids);
    }

    @Override
    public Page<T> findAll(Pageable pageable) {
        return baseRepository.findAll(pageable);
    }

    @Override
    public <S extends T> List<S> save(List<S> entities) {
        return baseRepository.save(entities);
    }

    @Override
    public <S extends T> S save(S entity) {
        return baseRepository.save(entity);
    }

    @Override
    public long count() {
        return baseRepository.count();
    }

    @Override
    public void delete(ID id) {
        baseRepository.delete(id);
    }

    @Override
    public void delete(T entity) {
        baseRepository.delete(entity);
    }

    @Override
    public void delete(List<? extends T> entities) {
        baseRepository.delete(entities);
    }

    @Override
    public void deleteAll() {
        baseRepository.deleteAll();
    }

    @Override
    public boolean exists(ID id) {
        return baseRepository.exists(id);
    }

    @Override
    public void flush() {
        baseRepository.flush();
    }
}
